package logic

import (
	"context"
	"fmt"
	"go-zero-demo/monitor/internal/svc"
	"go-zero-demo/monitor/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserInfoLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) UserInfoLogic {
	return UserInfoLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UserInfoLogic) UserInfo() (resp *types.UserInfoResponse, err error) {
	fmt.Println("实际开始了")
	//sql_1_1 := "select * from user"
	sql1:=l.svcCtx.Engine.GetSql("sql_4_1")
	var categoryinfo []types.UserInfoResponse
	err = l.svcCtx.Engine.SQL(sql1).Find(&categoryinfo)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(categoryinfo)
	resp = &categoryinfo[0]

	return resp,nil
}
